#ifndef Game_h__
#define Game_h__

#include <GTL.h>
#include <GTLEngine.h>

struct Reflector
{
	enum
	{
		REF_Serializing,
		REF_Deserializing,
	};
	int Mode;
	bool IsReading() const { return Mode == REF_Deserializing; }
	bool IsWriting() const { return Mode == REF_Serializing; }

	FILE* File;

	template <typename T>	void R(T& val) { val.Reflect(*this); }
	template <typename T>	void R(eastl::vector<T>& val) { 
		int size = val.size();
		R(size);
		val.resize(size);

		for (int i=0; i<size; i++)
		{
			R(val[i]);
		}
	}
	template <> void R(GTL::Geometry2D::GenericPoint2D<float>& val) { R(val.X); R(val.Y); }
	template <> void R(int& val) { if (Mode == REF_Deserializing) Read(val); else Write(val); }
	template <> void R(float& val) { if (Mode == REF_Deserializing) Read(val); else Write(val); }

	void Read(int& v);
	void Write(int& v);
	void Read(float& v);
	void Write(float& v);

	void Start(int mode, const char* filename);

	Reflector() : Mode(REF_Deserializing), File(0) {}
};

class TowerGame : public GTL::Engine::Game
{
public:
	virtual int StartGame();
	virtual GTL::Engine::Mode* CreateMode(int id, int arg1, int arg2);

private:
};

#endif // Game_h__